---@class GensLimts : Object
local GensLimts = {}
GensLimts.camps = {lord = 1,loyalist = 1,rebel = 2,renegade = 3}
GensLimts.totalwhites = {"godsimayi","chengjiw","olz__zhonghui","olmou__guanyu","tymou__caoshuang","tycl__sunquan","tycl__caocao","caojinyu","olmou__jiangwei","tianchou","caimaozhangyun","malingli","caoyi",
"zhouyi","mini__lvmeng","mini__weiyan","l__sunshangxiang","ty_ex__wangyi","ty__tongyuan","shibao","ol__fanchou","ol__feiyi","mou__liucheng","mobile__mamidi","mayuanyi","mobile__sufei","mini_ex__zhaoyun",
"js__luxun","zhenghun","sunchen","ty__pangdegong","fengfang","zhaoang","os__xujing","os_xing__zhanghe","ol_ex__liushan","yangyan","mobile__baosanniang",
"m_ex__caozhen","js__nanhualaoxian","mou__huanggai","mou__xuhuang","ol_ex__wolong","ty_ex__jianyong","ty_ex__gaoshun","ty_ex__liufeng","ty__cenhun","maliang","starsp__zhaoyun","ty__zhuling",
"os__zhugeguo","os__xuezong","luji","ty__sunluyu","zhangfen","ol_ex__xunyu","ol_ex__xiahouyuan","ty__liuye","nos__feiyi","yijik","ex__lvmeng","ex__zhaoyun","ex__guanyu","miniex__huangyueying","qinmi","mobile__mifuren","ex__guojia","caoang","ty_ex__zhuzhi","ty_ex__sunxiu","ty_ex__zhuran","ty_ex__guohuai","ty_ex__xusheng",
"ty_ex__lingtong","sunli","tystar__caoren","mu__caiwenji","ty__xujing","zhoubuyi","caomao","xuyou","olz__xunyou","chengjichengcui","ol__duyu","ol__lisu","ol__yanghu","ol__chendeng","ol__zhanghe","xizhicai","mou__huaxiong","mou__zhenji","mou__sunquan","mou__lvmeng","mobile__gaolan","mobile__yanghu","mobile__wujing",
"mobile__dongcheng","mobile__zhangyiy","yangbiao","js__zhangchu","js__zhanghe","l__lvbu","l__yuanshu","l__zhangliao","l__guanyu","l__raoyue","l__zhangfei","l__sunce","mobile__zhangchangpu","mobile__cuiyan","mobile__jiangqin","mobile__lvfan","mobile__huangfusong","m_ex__wuguotai","m_ex__xusheng","m_ex__yujin","m_ex__caozhi","m_ex__lingtong","m_ex__zhonghui","ty_ex__liubiao","m_ex__liaohua","m_ex__zhuran","m_ex__liru","m_ex__sunluban","m_ex__zhuhuan","m_ex__sunxiu","chengyu","ty__sunhao","shixie","cuiyan","tadun","litong","dongyun","heqi","liuqi","quyi","luzhiw","caoying","ol__gaolan","ol__huangzu",
"gaogan","ol__yangyi","ol__zhuling","fanjiangzhangda","qinghegongzhu","ol__tengfanglan","ol__zhugejin","ol__guyong","ol__zhoufei","ol__hetaihou","ol__machao","ol__huban","dongtuna","ol__zhangyiy","maxiumatie","ol__zhujun","sunhong","ol__hansui","ol__luyusheng","zhangyan","js__sunjian","js__huangfusong","js__dongbai","js__yangbiao","js__kongrong","js__wangrongh","js__duanwei","js__liubei","js__sunce","js__lvbu","js__guanyu","js__zhangliao","ol_ex__caoren","ol_ex__huangzhong","ol_ex__weiyan","ol_ex__zhoutai","ol_ex__zhangjiao","ol_ex__dianwei","ol_ex__taishici","ol_ex__yanliangwenchou","ol_ex__yuanshao","ol_ex__xuhuang","ol_ex__zhurong","ol_ex__menghuo","ol_ex__dongzhuo","m_ex__dengai","ol_ex__jiangwei","ol_ex__sunce","os_ex__zhangfei","os_ex__sunjian",
"os_ex__zhurong","os_ex__fazheng","os_ex__guohuai","os_ex__madai","os_ex__chengpu","os_ex__handang","os_ex__guyong","os_ex__caoxiu","fengxi","zhangnan","yuejiu","liufuren","os__dengzhi","os__jiachong","os__tianyu","os__fuwan","os__furong","liwei","niufudongxie","baoxin","os__guanqiujian","os_sp__caocao","ol__hejin","os__jiling","os__wuban","huchuquan","bingyuan","wufuluo","os__puyangxing","yanxiang","nya__xingcai","nya__zhurong","miniex__machao","mini__caocao","mini__zhangxingcai","mini__jiaxu","mini__pangde","mini_sp__jiangwei","mini__caoxiu","mobile__wangcan","chenzhen","luotong","mobile__duyu","xiangchong","mou__huangzhong","mou__machao","es__chendao","xiahouhui","ol__simashi","ol__yanghuiyu","olz__wuban","olz__wangling","haozhao","zhugezhan","godluxun","yuanshu","sp__pangde","hulao2__godlvbu","sp__caiwenji","ol__guanyinping","lingju","ty__xiahouba","chenlin","yuejin","zhangbao","xingcai","panfeng","ex__caocao","ex__simayi","ex__zhangliao","ex__xuchu","ex__zhenji","ex__ganning","ex__huanggai","ex__zhouyu","ex__lvbu","ol_ex__huaxiong","std__gongsunzan",
"ex__zhangfei","ex__huangyueying","std__xushu","yanjun","ty__lidian","liuyan","panjun","sp__pangtong","ty_ex__taishici","lvdai","liuyao","guansuo","ty__caochun","wenyang","ty__liuzan","leitong","chentai","ty__wangjun","guanlu","dukui","jianggan","ty__luotong","ty__wangchang","duanqiaoxiao","liubian","yuanji","xielingyu","guozhao","fanyufeng","ty__yangwan","ty__panshu","lijue","liangxing","shamoke","mangyachang","ty__xugong","mushun","ty__niujin","liyixiejing","ty__zhangning","ty__zhujun","ty__dingyuan","ty__hucheer","yanrou","ty__panfeng","caoxing","caiyang","zhoushan","zhangxuan","lvlingqi","panghui","chengui","ty__tangzi","ty__miheng","ty__huaxin","ty__xunchen","fengxiw","ty__zongyu","ty__yanghu","guanhai","sunru","liuzan","lingcao","ty__zhaotongzhaoguang","hujinding","maojie","peixiu","mxing__huangzhong","mobile__wangyuanji","fuqian","yangfu","qianzhao","gongsunkang","mxing__weiyan","ty_ex__wuyi","ty_ex__jvshou","ty_ex__huangyueying","lukai","wuanguo",}
GensLimts.qy_UnionGens = {"zhenghun","os_xing__zhanghe","ol_ex__liushan","yangyan","mou__xuhuang","ol_ex__wolong","ty_ex__liufeng","ty__cenhun","starsp__zhaoyun","os__xuezong","luji","ol_ex__xunyu","ol_ex__xiahouyuan","yijik","ex__lvmeng","ex__zhaoyun","ex__guanyu","qinmi","mobile__mifuren","ex__guojia","ty_ex__zhuzhi","ty_ex__sunxiu","ty_ex__zhuran","ty_ex__guohuai","ty_ex__xusheng","ol__chendeng","mou__huaxiong","mou__zhenji","ex__sunquan","mobile__gaolan","mobile__yanghu","mobile__dongcheng","mobile__zhangyiy","js__machao","l__yuanshu","l__raoyue","l__sunce","mobile__cuiyan","mobile__jiangqin","mobile__lvfan","m_ex__xusheng","m_ex__yujin","m_ex__lingtong","m_ex__zhonghui","ty_ex__liubiao","m_ex__zhuran","m_ex__sunluban","m_ex__zhuhuan","m_ex__sunxiu","chengyu","ty__sunhao","shixie","tadun","dongyun","heqi","liuqi","quyi","luzhiw","ol__gaolan","gaogan","ol__zhugejin","ol__guyong","ol__zhoufei","ol__hetaihou","ol__machao","ol__huban","maxiumatie","ol__zhujun","sunhong","ol__hansui","zhangyan","js__dongbai","js__kongrong","js__duanwei","js__lvbu","js__zhangliao","ol_ex__caoren","ol_ex__huangzhong","ol_ex__weiyan","ol_ex__zhoutai","ol_ex__taishici","ol_ex__xuhuang","ol_ex__zhurong","ol_ex__menghuo","ol_ex__dongzhuo","m_ex__dengai","ol_ex__jiangwei","ol_ex__sunce","os_ex__sunjian","os_ex__zhurong","os_ex__guyong","fengxi","zhangnan","yuejiu","liufuren","os__jiachong","os__fuwan","ol__hejin","os__jiling","os__wuban","yanxiang","mini_sp__jiangwei","mobile__wangcan","chenzhen","xiangchong","es__chendao","xiahouhui","ol__yanghuiyu","haozhao","zhugezhan","yangxiu","yuanshu","sp__pangde","sp__caiwenji","ol__guanyinping","lingju","chenlin","zhangbao","panfeng","ex__caocao","ex__simayi","ex__zhangliao","ex__xuchu","ex__zhenji","ex__ganning","ex__huanggai","ex__zhouyu","ex__lvbu","ol_ex__huaxiong","std__gongsunzan","ex__machao","ex__zhangfei","ex__huangyueying","std__xushu","lidian","panjun","sp__pangtong","lvdai","liuyao","yuanji","xielingyu","lijue","shamoke","ty__xugong","ty__niujin","ty__hucheer","chengui","ty__tangzi","ty__huaxin","ty__xunchen","fengxiw","ty__zongyu","sunru","liuzan","lingcao","hujinding","ty_ex__wuyi",}
GensLimts.diffStrongGens = {{
"ex__caocao","ex__simayi","ex__xiahoudun","qinmi","ex__zhangliao","ex__xuchu","ex__guojia","ex__zhenji","ex__liubei","ex__guanyu","ex__zhangfei","ex__zhugeliang","ex__zhaoyun","ex__machao","ex__huangyueying","std__xushu","yijik","ex__sunquan","ex__ganning","ex__lvmeng","ex__huanggai","ex__zhouyu","ex__luxun","ex__sunshangxiang","ex__huatuo","ex__lvbu","ex__diaochan","std__huaxiong","std__yuanshu","std__gongsunzan","sunru","lingcao","mxing__weiyan","mobile__dongcheng","mobile__shenpei","tongqu__jiakui","mobile__zhangyiy","yanpu","mayuanyi","mobile__mamidi","lifeng","yangfu","chengjiw","mobile__wangcan","chenzhen","mobile__wujing","caizhenji","xiangchong","mobile__jiangqin","m_ex__yujin","m_ex__caozhi","m_ex__zhonghui","m_ex__sunxiu","zhugeke","zhanglu","mayunlu","cuiyan","tadun","yanbaihu","litong","mizhu","buzhi","dongyun","xizhicai","sunqian","luzhiw","ol__xujing","ol__gaolan","gaogan","ol__zhuling","ol__chendeng","fanjiangzhangda","ahuinan","ol__furong","dongtuna","ol__zhangyiy","maxiumatie","ol__zhujun","zhangshiping","ol__luyusheng","zhangyan","ol__zhoufei","ol__machao","ol__guanyinping","ol__hetaihou","ol__dingfeng","ol__hejin","ol__niujin","ol__fanchou","ol__zhangbao","ol_sp__caoren","ol__guohuai","xuangongzhu","ol__wangyuanji","ol_ex__huaxiong","ol_ex__xiahouyuan","ol_ex__caoren","ol_ex__huangzhong","ol_ex__zhoutai","yanjun","sp__pangtong","liuyao","lvqian","leitong","ty__wangjun","ty__sunhao","ty__shixie","ty__lijueguosi","zhangji","ty__huban","qiuliju","ty__hucheer","chunyuqiong","caiyang","zhangxun","liupi","ty_ex__panzhangmazhong","js__huangfusong","js__dongbai","js__lvbu","js__zhangliao","js__zhangchu","l__yuanshu","l__raoyue","l__zhangfei","mini__caocao","mini__jiaxu","mini_sp__jiangwei","mou__liucheng","mou__huaxiong","mou__xuhuang","os_ex__zhangfei","os_ex__chengpu","os_ex__handang","fengxi","zhangnan","liufuren","os__dengzhi","os__jiachong","os__wuban","os__puyangxing","os__xuezong","os_xing__zhanghe","os__zhuling","os__simashi","luji","sp__pangde","sp__caiwenji","yuejin","caoang","nos__maliang","starsp__zhaoyun"
},{
"liuzan","hulao2__godlvbu","mou__machao","mxing__xuhuang","mxing__ganning","mxing__huangzhong","mxing__zhoubuyi","mobile__yanxiang","mobile__sufei","mobile__baosanniang","gongsunkang","maojie","mobile__wangyuanji","mobile__yanghuiyu","peixiu","qianzhao","simafu","luotong","mobile__duyu","mobile__zhouchu","mobile__yanghu","mobile__gaolan","mobile__zhangchangpu","mobile__cuiyan","mobile__lvfan","mobile__huangfusong","m_ex__wuguotai","m_ex__xusheng","m_ex__liaohua","m_ex__zhuran","m_ex__liru","m_ex__caozhen","m_ex__zhuhuan","chengyu","ol__mazhong","quyi","caoying","zhangling","wolongfengchu","ol__huangzu","ol__bianfuren","ol__yanghu","qinghegongzhu","ol__tengfanglan","weizi","guohuaij","dengzhong","ol__huban","luoxian","sunhong","ol__feiyi","tianchou","ol_sp__sunce","ol__jiangwan","ol__lingju","ol__zhugejin","ol__masu","ol__guyong","ol__lisu","simazhou","chengjichengcui","xiahouhui","ol__yanghuiyu","shibao","ol__duyu","yangyan","olz__xunchen","olz__wuban","olz__wangling","olz__wuqiao","olmou__jiangwei","olmou__taishici","ol_ex__weiyan","ol_ex__dianwei","ol_ex__wolong","ol_ex__pangtong","ol_ex__taishici","ol_ex__pangde","ol_ex__yanliangwenchou","ol_ex__xuhuang","ol_ex__menghuo","ol_ex__sunjian","ol_ex__dongzhuo","ol_ex__jiangwei","ol_ex__sunce","ol_ex__zhangzhaozhanghong","ol_ex__jianyong","ty__lidian","liuyan","panjun","lvdai","ty__caochun","ty__xiahouba","chentai","guanlu","gexuan","dukui","jianggan","zhaoang","xizheng","ty__liuqi","ty__luotong","ty__wangchang","ty__xinxianying","duanqiaoxiao","caomao","liubian","ty__liuyu","dingfuren","yuanji","ty__yangwan","ty__panshu","zhoubuyi","guanyueg","liangxing","duanwei","zhangheng","niufu","dongxie","shamoke","mangyachang","ty__xugong","fengfang","zhaozhong","mushun","ty__mifangfushiren","liyixiejing","sunhuan","sunlang","ty__guanyu","ty__hujinding","ty__tongyuan","ty__zhangning","ty__pangdegong","ty__hansui","ty__zhujun","ty__dingyuan","ty__dongcheng","ty__zhuling","yanrou","caoxing","zhoushan","zhanghu","ty__chendeng","chengui","ty__yuejiu","zhenghun","ty__miheng","ty__huaxin","ty__xunchen","ty__zongyu","ty__yanghu","xianglang",
"ty__yangyi","ty__zhangmancheng","mu__caiwenji","ty__panfeng","lukai","wuanguo","sunli","xukun","ty_ex__gaoshun","ty_ex__liubiao","ty_ex__guohuai","ty_ex__guanping","ty_ex__zhangsong","ty_ex__sunluban","ty_ex__jvshou","ty_ex__sunxiu","ty_ex__zhuzhi","ty_ex__taishici","js__nanhualaoxian","js__yangbiao","js__wangrongh","js__sunce","js__zhanghe","js__guojia","js__machao","l__lvbu","l__sunshangxiang","l__zhangliao","l__guanyu","miniex__machao","miniex__huangyueying","miniex__yuanshao","mou__xiahoushi","mou__lvmeng","mou__diaochan","os_ex__madai","os_ex__caoxiu","os__tianyu","os__fuwan","liwei","niufudongxie","baoxin","os__guanqiujian","os_sp__caocao","os__jiakui","os__jiling","bingyuan","wufuluo","os__zhugeguo","wenchou","xuyou","haozhao","zhugezhan","maliang"
},{
"fuqian","yangbiao","ol_sp__zhanghe","caoxiancaohua","wangguan","ol__peixiu","ol__simashi","olz__xunyou","olmou__guanyu","ol_ex__xunyu","ol_ex__yuanshao","ol_ex__jiaxu","ol_ex__wangyi","ty__guansuo","zhouyi","caoyi","wenyang","wangshuang","ty__liuzan","zhujianping","ty__liuye","xielingyu","caofang","guozhao","fanyufeng","caojinyu","zhangfen","ty__xujing","ty__sunluyu","zhangxuan","lvlingqi","tenggongzhu","panghui","ty__zhaotongzhaoguang","yuechen","sunchen","fengxiw","guanhai","mu__miheng","tystar__caoren","tycl__caocao","tycl__sunquan","ty_ex__lingtong","ty_ex__zhuran","ty_ex__wuyi","ty_ex__huangyueying","nya__zhurong","js__sunjian","js__liubei","js__guanyu","mini__weiyan","mini__zhangxingcai","mini__lvmeng","mini_ex__zhaoyun","mou__huanggai","mou__huangzhong","os_ex__guohuai","os__furong","huchuquan"
}}


local extarwhite={"thbattle__ailisi","thbattle__cheng","thbattle__qilunuo","thbattle__dayaojing",
"thbattle__bayiyonglin","thbattle__fulanduolu","thbattle__huiye","thbattle__xiaoemo","thbattle__xiaosan","thbattle__xiaoting",
"thbattle__molisha","thbattle__hongmeiling","thbattle__qiurangzi","thbattle__quanzouhua","thbattle__nazilin","thbattle__bayunlan",
"thbattle__lingmeng","thbattle__leimi","thbattle__xiaoye","thbattle__zaomiao","thbattle__huoqinge","thbattle__parsee","thbattle__patchouli",
"thbattle__rinnosuke","thbattle__shikieiki","thbattle__tewi","thbattle__yugi","thbattle__lumiya","thbattle__cuixiang",
"thbattle__tianzi","thbattle__yaomeng","thbattle__bayunzi","thbattle__youxiang","thbattle__meihong","thbattle__qinxin",
"thbattle__tuanzang","thbattle__zhengxie","thbattle__shennaizi","thbattle__meidixin","thbattle__wen","thbattle__sp_fulanduolu",
"thbattle__lingxian",
"thbattle__xiaowan","thbattle__hecheng","thbattle__qiujingye","thbattle__xiangzi","thbattle__huiyin","thbattle__uuz",
"th_nazrin","th_kogasa","th_ichirin","th_minamitsu","th_shou","th_byakuren","th_nue","th_kyouko","th_yoshika","th_seiga",
"th_aya","th_medicine","th_yuuka","th_onozuka","th_shikieiki","th_shizuha","th_minoriko","th_hina","th_nitori","th_momiji",
"th_sanae","th_kanako",
"th_suwako","th_kisume","th_yamame","th_parsee","th_yuugi","th_satori","th_rin","th_utsuho","th_koishi",
"th_reimu","th_marisa","th_rumia","th_daiyousei","th_cirno","th_meiling","th_koakuma","th_patchouli","th_sakuya","th_remilia","th_flandre","th_letty","th_chen","th_alice","th_lily",
"th_prismrivers","th_youmu","th_yuyuko","th_ran","th_yukari","th_wriggle","th_mystia","th_keine","th_tewi","th_reisen",
"th_eirin","th_kaguya","thsp__th_keine","th_mokou",}


table.insertTable(GensLimts.diffStrongGens[1],extarwhite)
table.insertTable(GensLimts.totalwhites,extarwhite)

function GensLimts:getDiffStrongGens(index)
  return index and GensLimts.diffStrongGens[index] or GensLimts.diffStrongGens
end

function GensLimts:getToTalGens()
  return GensLimts.totalwhites
end

function GensLimts:getQyUnionGens()
  return GensLimts.qy_UnionGens
end

function GensLimts:isGensPool(generals,genname)
  for i = 1, #generals do
    local gen = generals[i] and Fk.generals[generals[i]]
    if gen and genname == gen.name then
      table.remove(generals,i)
      return true
    end
  end
  return false
end

function GensLimts:isGensPools(generals,genname)
  for i = 1, #generals do
    for j = 1,#generals[i] do
      local gen = generals[i][j] and Fk.generals[generals[i][j]]
      if gen and genname == gen.name then
        table.remove(generals[i],j)
        return true
      end
    end
  end
  return false
end

function GensLimts:isSameCamp(player,target)
  return GensLimts.camps[player.role] == GensLimts.camps[target.role]
end

function GensLimts:gensIsInConf(selgens,gens_cfg)
  local correct_gens = {}
  for _,sel_g in ipairs(selgens) do
    for k,cfg_g in ipairs(gens_cfg) do
      if sel_g == cfg_g then
        table.insert(correct_gens,sel_g)
      end
    end
  end
  return #correct_gens == #selgens
end

function GensLimts:cntTnum(tb)
  local n = 0
  if not next(tb) then
    return n
  end
  for k,v in pairs(tb) do
    n = n + 1
  end
  return n
end



return GensLimts